<template>
  <div style="padding: 0 100px">

    <el-row>
      <el-col :span="17">
        <div style="float: left;padding-right: 30px">
          <el-image :src='"/api/fileserver/"+itemDetail.img' style="width: 180px;height: 250px" fit="cover"></el-image>
        </div>
        <div>
          <p style="font-weight: bold;font-size: 28px">{{ itemDetail.name }}</p>
          <p style=" font-family: cursive;color: #5a5e66">位 置： {{ itemDetail.seat }}</p>
          <p style="font-family: cursive;color: #5a5e66">发 布 于： {{ itemDetail.createTime }}</p>
          <p class="time">配 置： {{ itemDetail.teaSet }}茶具</p>
          <p class="time">价 格： {{ itemDetail.price }}元</p>
        </div>
      </el-col>
      <!-- 右侧宣誓 -->
      <el-col :span="7">
        <el-card shadow="never">
          <div>
            <h4 style="font-family: cursive; color: #5a5e66">要求：</h4>
            <p class="content"> 茶道茶馆。遵守茶文化，茶室内物品损坏照价赔偿。节约用水，用心品茶。</p>
          </div>
        </el-card>

      </el-col>
    </el-row>
    <el-col :offset="10">
      <el-button @click="con">取 消</el-button>
      <el-button type="primary" @click="toAdopt()">确 定</el-button>
    </el-col>
  </div>
</template>

<script>
import Api from "@/utils/api";
export default {
  name: "adoptDetail",
  props: ["itemDetail"],
  data() {
    return {
      isAds: true,
      starShow: true,
      isOpen: '',
      apply:{},
      priceDate: {},
      userInfo: {},
      item:{},
      house:{},
    }
  },
  mounted() {
    console.log(this.itemDetail)
    this.userInfo = JSON.parse(sessionStorage.getItem("userInfo"))
  },

  methods: {
    toAdopt() {
      this.isOpen = false
      this.apply.isOpen = false
      this.house.id = this.itemDetail.id
      this.house.isUse = 2 //预定房
      const today = new Date((new Date).getTime() + 8 * 60 * 60 * 1000);
      this.house.useTime = today.toJSON().split('T').join(' ').substring(0, 19); // 将1970/08/08转化成1970-08-08
      // console.log(this.house)
      this.upApi()
      this.priceDate.createUserName = this.userInfo.name
      this.priceDate.price = this.itemDetail.price
      this.priceDate.remark = '租用:' + this.itemDetail.name + '3小时'
      this.priceDate.house = this.itemDetail.name
      Api.upPrice(this.priceDate)
      this.$emit('apply', this.apply)
    },
    upApi() {
      this.$axios.post('/api/house/upHouse', this.house).then(res => {
        if (res.data.status === 1) {
          this.$notify({
            title: '提示',
            message: '订购成功',
            type: 'success'
          });
        } else {
          this.$notify({
            title: '提示',
            message: res.data.message,
            type: 'error'
          });
        }
      })
    },
    con() {
      this.$emit('apply', this.apply)
    }
  }

}
</script>

<style scoped>
.time {
  font-family: cursive;
  color: #5a5e66
}

.content {
  font-family: cursive;
  font-size: 20px;
}
</style>
